<?php
require_once '../Controller/ConnectFB.php';
require '../Controller/Config.php';
$userId = $fb_userData['id'];
//$userId = 1008;
?>
<?php
        $strq="SELECT DISTINCT
        poll.created_by,
        poll.poll_id,
        poll.poll_title,
        poll.created_date
        FROM
        poll WHERE created_by <> '".$userId."' AND poll.poll_id 
        NOT IN(SELECT answer.poll_id FROM answer WHERE answer.user_id = '".$userId."' GROUP BY poll_id)";
                    $strqr=mysql_query($strq);
                    $num_row = @mysql_num_rows($strqr);
//                    echo $strq;
                    if($num_row==0){
                        ?>
<html>
    <body>
        
                    <table width="100%" border="0" padding="0" margin="0">
                            <tr valign="top" height="40px">
                                <td colspan="3" border="1" align="center" valign="middle" bgcolor="#e96c10">
                                    <font color="#ffffff" size="4" align="center"><b>แบบสอบถามที่ท่านไม่เคยตอบ</b></font>
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                                    <font size="4" align="center">ไม่มีแบบสอบถามที่ท่านไม่เคยตอบ</font>
                                </td>
                            </tr>
                    </table>
                        <?php    
                    }else{
                        $count = 1;
                        ?>
                        <table width="100%" border="0">
                            <tr  valign="top" height="40px">
                                <td colspan="3" border="1" align="center" valign="middle" bgcolor="#e96c10">
                                     <font color="#ffffff" size="4" align="left"><b>แบบสอบถามที่ท่านไม่เคยตอบ</b></font>
                                </td>
                            </tr>
                        <tr align="center" bgcolor="#ee974a" height="30px">
                            <td>
                                <font color="#ffffff"><b>ลำดับที่</b></font>
                            </td>
                            <td>
                                <font color="#ffffff"><b>ชื่อแบบสอบถาม</b></font>
                            </td>
                            <td>
                                <font color="#ffffff"><b>วันที่สร้าง</b></font>
                            </td>
                           
                        </tr>
                        <?php
                        while($rs=mysql_fetch_array($strqr)){  
                            $date = new DateTime($rs['created_date']);
                            
                 if($count%2==0){
                            $bgcolor = "#ffffff";
                        }else{
                            $bgcolor = "#f6d6a5";
                        } 
                ?>      
                        <tr align="center" bgcolor="<?php echo $bgcolor ?>" height="25px">
                            <td>
                                <font><?php echo $count?></font>
                            </td>
                            <td>
                                <font><a href="?page=CheckCondition&pollId=<?php echo $rs['poll_id']?>&poll=<?php echo $rs['poll_title']?>" ><?php echo $rs['poll_title']?></a></font>
                            </td>
                            <td>
                                <font><?php echo $date->format("d/m/Y")?></font>
                            </td>                        
                        </tr>
                        
                <?php 
                            $count++;
                        }
                        mysql_close();
                       ?>
        </table>
                <?php
                        
                    }
                    ?>
    </body>
</html>
                          
